#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int maxArea(vector<int>& height) {
        int n = height.size();
        int left = 0, right = n - 1;
        int volume = 0;
        while (left < right) {
            volume = max(volume, (right - left) * min(height[left], height[right]));
            if (height[left] <= height[right]) {
                left++;
            }
            else {
                right--;
            }
        }
        return volume;
    }
};